package club.justwill.single.persistence.store;

import club.justwill.single.persistence.document.MongoDocument;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;

import java.util.Collection;

/**
 * Created by xiangnan on 16-1-14.
 */
public class MongoDbStore<T extends MongoDocument> {

    @Autowired
    protected MongoTemplate mongoTemplate;

    public void insert(T obj) {
        mongoTemplate.insert(obj);
    }

    public void insertAll(Collection<T> objs){
        mongoTemplate.insertAll(objs);
    }
    public void save(T obj) {
        mongoTemplate.save(obj);
    }
    public void remove(T obj){
        mongoTemplate.remove(obj);
    }
}
